﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.RightsManagement;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using WpfApp3.Views;

namespace WpfApp3.ViewModels
{
    //BindableBase实现属性动态通知
    public class MainViewModel: BindableBase
    {
        //IRegionManager是prism框架中的一个关键接口，用于管理和控制应用程序中的不同区域（Region）
        private readonly IRegionManager _regionManager;


        //定义4个命令
        public DelegateCommand OpenACommand { get; private set; }
        public DelegateCommand OpenBCommand { get; private set; }
        public DelegateCommand OpenCCommand { get; private set; }
        public DelegateCommand OpenDCommand { get; private set; }


        //构造函数
        public MainViewModel(IRegionManager regionManager)
        {
            OpenACommand = new DelegateCommand(OpenA);
            OpenACommand = new DelegateCommand(OpenB);
            OpenACommand = new DelegateCommand(OpenC);
            OpenACommand = new DelegateCommand(OpenD);

            _regionManager = regionManager;
            _regionManager.RegisterViewWithRegion("ARegion", typeof(HHHView));
            _regionManager.RegisterViewWithRegion("ContentRegion", typeof(AAAView));
        }


        private void OpenA()
        {
            _regionManager.RequestNavigate("ContentRegion", "AAAView");  
        }

        private void OpenB()
        {
            _regionManager.RequestNavigate("ContentRegion", "BBBView");
        }

        private void OpenC()
        {
            _regionManager.RequestNavigate("ContentRegion", "CCCView");
        }

        private void OpenD()
        {
            _regionManager.RequestNavigate("ContentRegion", "DDDView");
        }
    }
}
